﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Solution2DModel>" %>

<asp:Content ContentPlaceHolderID="TitleContent" runat="server">
    <%= (string)GetLocalResourceObject("Page.Title") %>
</asp:Content>
<asp:Content ContentPlaceHolderID="PageHeader" runat="server">
    <%= (string)GetLocalResourceObject("Page.Title") %>
</asp:Content>


<asp:Content ContentPlaceHolderID="MainContent" runat="server">
    <script language="javascript" type="text/javascript">
        var apiURL = "http://chart.apis.google.com/chart?cht=tx&chs=1x0&chf=bg,s,FFFFFF00&chco=000000&chl=";
        var formula = "\\[ \\left\\{ \\begin{array}{l l} \\Delta u = f\\\\ u = {g} \\quad \\text{ on $x$={x1}, $y$={y1}, $z$={z1}, $x$={x2}, $y$={y2}, $z$={z2}}  \\\\ \\end{array} \\right.\\]";

        $(function () {
            $("#inpX1").keyup(function (e) {
                updateFormula();
            });
            $("#inpX2").keyup(function (e) {
                updateFormula();
            });
            $("#inpY1").keyup(function (e) {
                updateFormula();
            });
            $("#inpY2").keyup(function (e) {
                updateFormula();
            });
            $("#inpZ1").keyup(function (e) {
                updateFormula();
            });
            $("#inpZ2").keyup(function (e) {
                updateFormula();
            });
            $("#inpG").keyup(function (e) {
                updateFormula();
            });
        });

        function updateFormula() {
            var vars = [["#inpX1", "{x1}"],
                        ["#inpX2", "{x2}"],
                        ["#inpY1", "{y1}"],
                        ["#inpY2", "{y2}"],
                        ["#inpZ1", "{z1}"],
                        ["#inpZ2", "{z2}"],
                        ["#inpG", "{g}"], ];

            var f = formula;
            for (var i in vars) {
                var v = vars[i];
                f = insertValueInFormula(f, v[0], v[1]);
            }
            $("#imgFormula").attr("src", apiURL + f);
            $("#imgFormula").attr("alt", f);
        }

        function insertValueInFormula(f, element, pattern) {
            var text = $(element).val();
            return f.replace(pattern, text);
        }
    </script>
    
    <%
        using (Html.BeginForm("Step3", "Solution", new {}, FormMethod.Post, new { id = "solveEquation" }))
        { %>
            <div class="problem">
                <fieldset class="fs-input-params">
                    <legend><%= (string)GetLocalResourceObject("InputParams")%></legend>
                    <table class="form-input-params">
                        <tr>
                            <td class="label">
                                <label for="<%= Reflector.GetPropertyName<SolutionModel>(x => x.Problem.InputParameters.N) %>">
                                    <%= (string)GetLocalResourceObject("PointsCount")%>
                                </label>
                            </td>
                            <td class="value">
                                <%= Html.TextBoxFor(x => x.Problem.InputParameters.N ) %>
                            </td>
                            <td class="hint"><%= (string)GetLocalResourceObject("PointsCount.Hint")%></td>
                        </tr>
                        <tr>
                            <td class="label">
                                <label for="inpX1">
                                    <%= (string)GetLocalResourceObject("x1")%>
                                </label>
                            </td>
                            <td class="value">
                                <%= Html.TextBoxFor(x => x.Problem.InputParameters.X1, new { id = "inpX1" })%>
                            </td>
                        </tr>
                        <tr>
                            <td class="label">
                                <label for="inpX2">
                                    <%= (string)GetLocalResourceObject("x2")%>
                                </label>
                            </td>
                            <td class="value">
                                <%= Html.TextBoxFor(x => x.Problem.InputParameters.X2, new { id = "inpX2" })%>
                            </td>
                        </tr>
                        <tr>
                            <td class="label">
                                <label for="inpY1">
                                    <%= (string)GetLocalResourceObject("y1")%>
                                </label>
                            </td>
                            <td class="value">
                                <%= Html.TextBoxFor(x => x.Problem.InputParameters.Y1, new { id = "inpY1" })%>
                            </td>
                        </tr>
                        <tr>
                            <td class="label">
                                <label for="inpY2">
                                    <%= (string)GetLocalResourceObject("y2")%>
                                </label>
                            </td>
                            <td class="value">
                                <%= Html.TextBoxFor(x => x.Problem.InputParameters.Y2, new { id = "inpY2" })%>
                            </td>
                        </tr>
                        <%--<tr>
                            <td class="label">
                                <label for="inpZ1">
                                    <%= (string)GetLocalResourceObject("z1")%>
                                </label>
                            </td>
                            <td class="value">
                                <%= Html.TextBoxFor(x => x.Problem.InputParameters.Z1, new { id = "inpZ1" })%>
                            </td>
                        </tr>
                        <tr>
                            <td class="label">
                                <label for="inpZ2">
                                    <%= (string)GetLocalResourceObject("z2")%>
                                </label>
                            </td>
                            <td class="value">
                                <%= Html.TextBoxFor(x => x.Problem.InputParameters.Z2, new { id = "inpZ2" })%>
                            </td>
                        </tr>--%>
                        <tr>
                            <td class="label">
                                <label for="f">
                                    <%= (string)GetLocalResourceObject("LeftPart")%>
                                </label>
                            </td>
                            <td class="value"><%= Html.TextBox("f", "") %></td>
                            <td class="hint"><%= (string)GetLocalResourceObject("LeftPart.Hint")%></td>
                        </tr>
                        <tr>
                            <td class="label">
                                <label for="inpG">
                                    <%= (string)GetLocalResourceObject("ValueOnBoundary")%>
                                </label>
                            </td>
                            <td class="value"><%= Html.TextBoxFor(x => x.Problem.InputParameters.G, new { id = "inpG" })%></td>
                            <td class="hint"><%= (string)GetLocalResourceObject("ValueOnBoundary.Hint")%></td>
                        </tr>
                        <tr>
                            <td class="label">
                                <label for="<%= Reflector.GetPropertyName<SolutionModel>(x => x.Problem.InputParameters.Epsilon) %>">
                                    <%= (string)GetLocalResourceObject("Epsilon")%>
                                </label>
                            </td>
                            <td class="value"><%= Html.TextBoxFor(x => x.Problem.InputParameters.Epsilon)%></td>
                            <td class="hint"><%= (string)GetLocalResourceObject("Epsilon.Hint")%></td>
                        </tr>
                        <tr>
                            <td class="label">
                                <label for="<%= Reflector.GetPropertyName<SolutionModel>(x => x.Problem.InputParameters.H) %>">
                                    <%= (string)GetLocalResourceObject("H")%>
                                </label>
                            </td>
                            <td class="value"><%= Html.TextBoxFor(x => x.Problem.InputParameters.H)%></td>
                            <td class="hint"><%= (string)GetLocalResourceObject("H.Hint")%></td>
                        </tr>
                        <tr>
                            <td class="label">
                                <label for="<%= Reflector.GetPropertyName<SolutionModel>(x => x.Problem.InputParameters.Alpha) %>">
                                    <%= (string)GetLocalResourceObject("Alpha")%>
                                </label>
                            </td>
                            <td class="value"><%= Html.TextBoxFor(x => x.Problem.InputParameters.Alpha)%></td>
                            <td class="hint"><%= (string)GetLocalResourceObject("Alpha.Hint")%></td>
                        </tr>
                    </table>
                </fieldset>
            </div>
    
           <div class="solution">
               <%--<fieldset class="fs-problem">
                    <legend><%= (string)GetLocalResourceObject("Problem")%></legend>
                        <img id="imgFormula" title="<%= (string)GetLocalResourceObject("Problem")%>"
                             src="http://chart.apis.google.com/chart?cht=tx&chs=1x0&chf=bg,s,FFFFFF00&chco=000000&chl=\[ \left\{ \begin{array}{l l} \Delta u = f\\ u= <%= Model.Problem.InputParameters.G %> \quad \text{ on $x$=<%= Model.Problem.InputParameters.X1 %>, $y$=<%= Model.Problem.InputParameters.Y1 %>, $z$=<%= Model.Problem.InputParameters.Z1 %>, $x$=<%= Model.Problem.InputParameters.X2 %>, $y$=<%= Model.Problem.InputParameters.Y2 %>, $z$=<%= Model.Problem.InputParameters.Z2 %>}  \\ \end{array} \right.\]">
                </fieldset>--%>
                <input type="submit" value="<%= (string)GetLocalResourceObject("Button.Solve")%>" />
           </div>
    <%  }%>

</asp:Content>